package crmdna.custom.isha;

import java.util.List;

import javax.inject.Named;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiMethod.HttpMethod;
import com.google.appengine.api.users.User;

import crmdna.client.member.Member.CheckInMemberProp;
import crmdna.common.APIResponse;
import crmdna.common.APIResponse.Status;
import crmdna.common.Utils;

@Api(name = "isha")
public class IshaMemberApi {
	
	@ApiMethod(path = "getMembersForCheckIn", httpMethod = HttpMethod.GET)
	public APIResponse getMembersForCheckIn(@Named("searchStr") String searchStr, 
			@Named("programId") long programId, 
			@Named("sessionDateYYYYMMDD") int sessionDateYYYYMMDD, 
			@Named("maxResultsSize") Integer maxResultsSize, User user) {
		try {
			
			if (maxResultsSize == null)
				maxResultsSize = 25; //default value
			
			List<CheckInMemberProp> checkInMemberProps = 
					IshaMember.getMembersForCheckIn(searchStr, programId, sessionDateYYYYMMDD, 
							25, Utils.getLoginEmail(user));							
			
			return new APIResponse(Status.SUCCESS, checkInMemberProps);
			
		} catch (Exception ex) {
			return new APIResponse(ex);
		}
	}	
}
